package com.wujunshen.common.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author Jason Song(song_s@ctrip.com)
 */
@RefreshScope
@Component("annotatedBean")
@Slf4j
public class AnnotatedBean {
    @Value("${timeout:200}")
    private int timeout;
    private int batch;

    @PostConstruct
    void initialize() {
        log.info("timeout is initialized as {}", timeout);
        log.info("batch is initialized as {}", batch);
    }

    @Value("${batch:100}")
    public void setBatch(int batch) {
        this.batch = batch;
    }

    @Override
    public String toString() {
        return String.format("[AnnotatedBean] timeout: %d, batch: %d", timeout, batch);
    }
}